package com.bcxj.serviceorder.config;

import io.lettuce.core.dynamic.annotation.CommandNaming;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import javax.validation.Valid;

/**
 * ClassName: RedisConfig
 * Package: com.bcxj.serviceorder.config
 * Description:
 *
 * @Author BCXJ
 * @Create 2024/11/20 16:34
 * @Version 1.0
 * @Since 1.0
 */
@Component
public class RedisConfig {

    private String potocol = "redis://";

    @Value("${spring.redis.host}")
    private String redisHost;

    @Value("${spring.redis.port}")
    private String redisPort;

    @Value("${spring.redis.password}")
    private String redisPassword;

    @Bean
    public RedissonClient redissonClient() {
        Config config = new Config();
        config.useSingleServer().setAddress(potocol + redisHost + ":" + redisPort).setPassword(redisPassword).setDatabase(0);
        return Redisson.create(config);
    }
}
